package com.mini.service;

import com.mini.model.BusinessCity;
import com.mini.repository.BusinessCityRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * @author: zhaocg
 * @created: 2021/01/14 15:23
 */
@Service
public class BusinessCityService extends BaseService {

    @Autowired
    private BusinessCityRepository cityRepository;


    /**
     * 获取全部省份
     *
     * @return
     */
    public List<BusinessCity> getProvinceList(){
        return cityRepository.findByLevel(2);
    }

    /**
     * 根父编码获取所属城市
     *
     * @param pCode
     * @return
     */
    public List<BusinessCity> findByPcode(String pCode){
        return cityRepository.findByPcode(pCode);
    }

    /**
     * 根据编码获取城市详情
     *
     * @param code
     * @return
     */
    public BusinessCity findByCode(String code){
        return cityRepository.findByCode(code);
    }

}
